﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class MapControl
{
    public MapControl()
    {
    }

    internal void loadFirstMap(out int[,] sceneryMatriz, out int[,] collisionMatriz, out int[,] objectsMatriz, out int[,] eventsMatriz)
    {
        loadMap(1, out sceneryMatriz, out collisionMatriz, out objectsMatriz, out eventsMatriz);
    }

    internal void loadMap(int mapID, out int[,] sceneryMatriz, out int[,] collisionMatriz, out int[,] objectsMatriz, out int[,] eventsMatriz)
    {
        int[,] scenery = new int[20, 12];

        int[,] objects = new int[20 , 12];

        int[,] collision = new int[20, 12];

        int[,] events = new int[3, 40];

        FileStream fs = new FileStream("Content/Maps/" + mapID + ".txt", FileMode.Open, FileAccess.Read);
        BinaryReader r = new BinaryReader(fs);

        for (int j = 0; j < 20; j++)
            for (int k = 0; k < 12; k++)
            {
                scenery[j,k] = r.ReadInt32();
            }

        for (int j = 0; j < 20; j++)
            for (int k = 0; k < 12; k++)
            {
                objects[j,k] = r.ReadInt32();
            }

        for (int j = 0; j < 20; j++)
            for (int k = 0; k < 12; k++)
            {
                collision[j,k] = r.ReadInt32();
            }

        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 40; k++)
            {
                events[j, k] = r.ReadInt32();
            }

        r.Close();

        sceneryMatriz = scenery;
        collisionMatriz = collision;
        objectsMatriz = objects;
        eventsMatriz = events;
    }
}
